package com.my.study.designPatterns.templatePattern;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Objects;
import java.util.Scanner;

public class TeaWithHook extends CoffeinBeverageWithHook {

    @Override
    void brew() {
        System.out.println("Put Tea into cup-------");
    }

    @Override
    void addCondiments() {

        System.out.println("Add some lemon to tea");
    }

    @Override
    public Boolean needCondiments() {

        String answer = getInputAnswer();
        if(Objects.equals("y", answer)){
            return true;
        }
        return false;
    }


    private String getInputAnswer(){

        String answer = null;
        System.out.println("Would you like add lemmo to your coffee? (y/n)");
        Scanner scanner = new Scanner(System.in);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        try{
            answer =  bufferedReader.readLine();
        }catch (Exception e){

            e.printStackTrace();
        }
        if(answer == null){
            answer = "n";
        }
        return answer;


    }
}
